<template>
  <div>这里是News</div>

  <div class="nav">
    <div class="left">
      <div v-for="item in list" :key="item.id" @click="lookContent(item.id)">{{ item.title }}</div>
    </div>

    <div class="right">
      <RouterView></RouterView>
    </div>
    <div>
      <About></About>
    </div>
  </div>
</template>

<script setup>
import router from '@/router'
import { reactive } from 'vue'
import { RouterView } from 'vue-router'
import About from './About.vue'

import { onMounted, onUnmounted } from 'vue'

onMounted(() => {
  console.log('News挂载了')
})
onUnmounted(() => {
  console.log('News卸载了')
})

let list = reactive([
  { id: '1', title: '哎呦你干嘛', content: 'haha' },
  { id: '2', title: '芜湖起飞', content: '起飞' },
  { id: '3', title: '猜猜', content: '今天放假' }
])

const lookContent = (id) => {
  console.log('点击了')
  // router.push({ path: '/News/NewsDetail', query: { id: id } })
  router.push({ name: 'NewsDetail', params: { id: id } })
}
</script>

<style lang="scss" scoped>
.nav {
  display: flex;
  margin-top: 20px;

  .left {
    flex: 1;
    background-color: #dadada;
  }

  .right {
    flex: 2;
    background-color: #e2edf0;
  }
}
</style>
